package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Appointment;
import cn.wolfcode.car.mapper.AppointmentMapper;
import cn.wolfcode.car.qo.AppointmentQueryObject;
import cn.wolfcode.car.service.IAppointmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AppointmentServiceImpl implements IAppointmentService {

    @Autowired
    private AppointmentMapper appointmentMapper;

    @Override
    public int delete(Long id) {
        return appointmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Appointment record) {
        return appointmentMapper.insert(record);
    }

    @Override
    public Appointment get(Long id) {
        return appointmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Appointment> list(AppointmentQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Appointment> list = appointmentMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<Appointment> listAll() {
        return appointmentMapper.selectAll();
    }

    @Override
    public int update(Appointment record) {
        return appointmentMapper.updateByPrimaryKey(record);
    }


}
